package com.bsoft.wx.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bsoft.wx.pojo.TestSayHelloForm;
import com.bsoft.wx.service.SysConfigService;
import com.bsoft.wx.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author hdh
 * @ Data   :Created in 23:00 2023/1/12
 * @ Description
 * @ Modified By: hdh
 * @ Version : 1.0
 */
@Slf4j
@RestController
@Api("测试接口")
@RequestMapping("/test")
public class SayHello {
    @Autowired
    SysConfigService sysConfigService;

    @PostMapping("/sayHello")
    @ApiOperation("最简单的测试方法")
    public R sayHello(@Valid @RequestBody TestSayHelloForm testSayHelloForm) {
        log.info("-----------" + testSayHelloForm.getName());
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("status", 1);
        List list = sysConfigService.list(queryWrapper);
        return R.ok().put("message", "hello" + testSayHelloForm.getName());
    }

    @PostMapping("/addUser")
    @ApiOperation("添加用户")
    @RequiresPermissions(value = {"ROOT", "USER:ADD"}, logical = Logical.OR)
    public R addUser() {
        return R.ok();
    }
}
